package test;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.util.Properties;

public class LocalProperties {

	String PROPERTIES_FILE = "";

	public LocalProperties(String File_Path) {
		PROPERTIES_FILE = File_Path;
	}

	public String getProperty(String KeyName) {
		String value = null;

		try {
			Properties props = new Properties();
			FileInputStream fis = new FileInputStream(PROPERTIES_FILE);
			props.load(new java.io.BufferedInputStream(fis));
			value = props.getProperty(KeyName).trim();
			fis.close();
		} catch (java.lang.Exception e) {
			System.out.println(e.toString());
		}
		return value;
	}

	public String setProperty(String keyName, String value) {
		try {
			Properties props = new Properties();
			FileInputStream fis = new FileInputStream(PROPERTIES_FILE);
			props.load(new java.io.BufferedInputStream(fis));
			props.setProperty(keyName, value);
			props.store(new FileOutputStream(PROPERTIES_FILE), "");
			fis.close();
		} catch (java.lang.Exception e) {
			System.out.println(e.toString());
		}
		return value;
	}
}
